#ifndef __C3D_H__
#define __C3D_H__

#include "vl/vld.h"
#include <vector>
#include <time.h>

///////////////////////////////////////////////////////////////////////
//  C3D file reader and writer
///////////////////////////////////////////////////////////////////////

#define C3D_REC_SIZE   512

typedef struct c3d_head_t {
	unsigned char	prec_start;
	unsigned char	key;
	short	pnt_cnt;
	short	a_channels;
	short	start_frame;
	short	end_frame;
	short	int_gap;
	float	scale;
	short	rec_start;
	short	a_frames;
	float	freq;
	short	stuff[244];	
} c3d_head;

typedef struct c3d_param_t {
	unsigned char	reserved[2];
	unsigned char	pblocks;
	unsigned char	ftype;
	char stuff[C3D_REC_SIZE-4];	
} c3d_param;

typedef struct c3d_frameSI_t {
	short	x, y, z;
	unsigned char	cam_byte;
	unsigned char	residual;
} c3d_frameSI;

typedef struct c3d_frame_t {
	float	x, y, z;
	float	residual;
} c3d_frame;

float ConvertDecToFloat(char bytes[4]);
void ConvertFloatToDec(float f, char* bytes);
bool LoadC3DFile( const char *fileName, std::vector<Vec3d> & mPointData, int *nFrame, int *nMarker );

double maxElem(std::vector<double> & arr, int & index);
double minElem(std::vector<double> & arr, int & index);

#endif

